<extend name="_layout/main" />
<block name="head">
    <style>
        .bootbox-body img {
            max-width: 100%!important;
        }
    </style>

</block>
<block name="content">
    <div class="page-content">
        <div class="page-breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="fa fa-home"></i>
                    <a href="{:U('dashboard/index')}">系统首页</a>
                </li>
                <li>
                    <a href="javascript:;">商品管理</a>
                </li>
                <li class="active">商品列表</li>
            </ul>
        </div>

        <div class="page-body">
            <div class="row">
                <div class="col-lg-12 col-sm-12 col-xs-12">
                    <div class="widget">
                        <div class="widget-header bordered-left bordered-darkorange">
                            <span class="widget-caption">{$category['name']}</span>
                            <div class="widget-buttons">

                                <a href="#" data-toggle="collapse">
                                    <i class="fa fa-minus"></i>
                                </a>
                                <a href="#" data-toggle="dispose">
                                    <i class="fa fa-times"></i>
                                </a>
                            </div>
                        </div>
                        <div class="widget-body bordered-left bordered-warning">
                            <form class="form-inline" role="form">
                                <input type="hidden" value="{:I('catid')}" name="catid" />
                                <div class="form-group">
                                    <input type="text" class="form-control" name="keyword" placeholder="商品名称" value="{$Think.request.keyword}">
                                </div>

                                <button type="submit" class="btn btn-default">搜索</button>

                                <a href="{:U('goods/add',['catid'=>$category['id']])}" class="btn btn-darkorange pull-right">
                                    <i class="fa fa-plus"></i> 添加商品
                                </a>
                            </form>

                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12 col-md-12">
                    <form method="post" id="listForm">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <!--<th class="text-center" width="80">-->
                                    <!--<label>-->
                                        <!--<input type="checkbox" class="colored-success select-all">-->
                                        <!--<span class="text"></span>-->
                                    <!--</label>-->
                                <!--</th>-->
                                <th class="text-center" width="80">ID</th>
                                <th  class="text-center">商家</th>
                                <th>商品名称</th>
                                <th class="text-center" >商品价格</th>
                                <th class="text-center" >商品库存</th>
                                <th class="text-center" >猜你喜欢</th>
                                <th class="text-center" >热门推荐</th>
                                <th class="text-center" >每周上新</th>
                                <th class="text-center" width="200">操作</th>
                            </tr>
                            </thead>
                            <volist name="result" id="val">
                                <tr>
                                    <!--<td class="text-center">-->
                                        <!--<label>-->
                                            <!--<input type="checkbox" name="id[{$val.id}]" value="{$val.id}" class="colored-success select-item">-->
                                            <!--<span class="text"></span>-->
                                        <!--</label>-->
                                    <!--</td>-->
                                    <td class="text-center">{$val.id}</td>
                                    <td class="text-center">{$val['supplier_id'] ? $val['nickname'] : '【平台自营】'}</td>
                                    <td>{$val.goods_name}</td>
                                    <td class="text-center">现金{$val.pay_balance} + 积分{$val.pay_integral} + 券{$val.pay_coupon}</td>
                                    <td class="text-center">{$val.goods_number}</td>
                                    <td class="text-center">
                                        <div class="btn-group">
                                            <eq name="val.recommend" value="1">
                                                <a class="btn btn-sm btn-palegreen">显示</a>
                                                <a class="btn btn-sm btn-palegreen dropdown-toggle"
                                                   data-toggle="dropdown" aria-expanded="false"><i
                                                        class="fa fa-angle-down"></i></a>
                                                <ul class="dropdown-menu palegreen" role="menu">
                                                    <li>
                                                        <a href="{:U('goods/recommend',['id'=>$val['id'],'_type'=>0])}"
                                                           data-confirm="确认隐藏该商品？">隐藏</a>
                                                    </li>
                                                </ul>
                                                <else/>
                                                <a class="btn btn-sm btn-danger">隐藏</a>
                                                <a class="btn btn-sm btn-danger dropdown-toggle"
                                                   data-toggle="dropdown" aria-expanded="false"><i
                                                        class="fa fa-angle-down"></i></a>
                                                <ul class="dropdown-menu danger" role="menu">
                                                    <li>
                                                        <a href="{:U('goods/recommend',['id'=>$val['id'],'_type'=>1])}"
                                                           data-confirm="确认显示该商品？">显示</a>
                                                    </li>
                                                </ul>
                                            </eq>
                                        </div>
                                    </td>
                                    <td class="text-center">
                                        <div class="btn-group">
                                            <eq name="val.hot" value="1">
                                                <a class="btn btn-sm btn-palegreen">热卖</a>
                                                <a class="btn btn-sm btn-palegreen dropdown-toggle"
                                                   data-toggle="dropdown" aria-expanded="false"><i
                                                        class="fa fa-angle-down"></i></a>
                                                <ul class="dropdown-menu palegreen" role="menu">
                                                    <li>
                                                        <a href="{:U('goods/hot',['id'=>$val['id'],'_type'=>0])}"
                                                           data-confirm="确认取消热卖？">取消热卖</a>
                                                    </li>
                                                </ul>
                                                <else/>
                                                <a class="btn btn-sm btn-danger">正常</a>
                                                <a class="btn btn-sm btn-danger dropdown-toggle"
                                                   data-toggle="dropdown" aria-expanded="false"><i
                                                        class="fa fa-angle-down"></i></a>
                                                <ul class="dropdown-menu danger" role="menu">
                                                    <li>
                                                        <a href="{:U('goods/hot',['id'=>$val['id'],'_type'=>1])}"
                                                           data-confirm="确认设置该商品为热卖？">置为热卖</a>
                                                    </li>
                                                </ul>
                                            </eq>
                                        </div>
                                    </td>
                                    <td class="text-center">
                                        <div class="btn-group">
                                            <eq name="val.newest" value="1">
                                                <a class="btn btn-sm btn-palegreen">新品</a>
                                                <a class="btn btn-sm btn-palegreen dropdown-toggle"
                                                   data-toggle="dropdown" aria-expanded="false"><i
                                                        class="fa fa-angle-down"></i></a>
                                                <ul class="dropdown-menu palegreen" role="menu">
                                                    <li>
                                                        <a href="{:U('goods/newest',['id'=>$val['id'],'_type'=>0])}"
                                                           data-confirm="确认取消新品？">取消新品</a>
                                                    </li>
                                                </ul>
                                                <else/>
                                                <a class="btn btn-sm btn-danger">正常</a>
                                                <a class="btn btn-sm btn-danger dropdown-toggle"
                                                   data-toggle="dropdown" aria-expanded="false"><i
                                                        class="fa fa-angle-down"></i></a>
                                                <ul class="dropdown-menu danger" role="menu">
                                                    <li>
                                                        <a href="{:U('goods/newest',['id'=>$val['id'],'_type'=>1])}"
                                                           data-confirm="确认设置该商品为新品？">置为新品</a>
                                                    </li>
                                                </ul>
                                            </eq>
                                        </div>
                                    </td>
                                    <td class="text-center">
                                        <a href="{:U('goods/comment',['goods_id'=>$val['id']])}" class="btn btn-default btn-xs"><i class="fa  fa-eye"></i>评论</a>
                                        <a href="{:U('goods/edit',['id'=>$val['id']])}" class="btn btn-default btn-xs"><i class="fa  fa-edit"></i>编辑</a>
                                        <a href="{:U('goods/delete',['id'=>$val['id']])}" class="btn btn-danger btn-xs white" data-confirm="确定删除该商品?"><i class="fa fa-trash-o"></i>删除</a>

                                    </td>

                                </tr>
                            </volist>
                            <tbody>
                            </tbody>
                        </table>
                        <div class="row DTTTFooter">
                            <div class="col-sm-6">
                                <div class="dataTables_info" id="simpledatatable_info" role="status" aria-live="polite">
                                    <div class="buttons-preview">
                                        <!--<a href="javascript:void(0);" class="btn btn-danger shiny" id="delete"  data-action="{:U('goods/delete')}" data-confirmtext="确定删除已选中的商品？">删除</a>-->
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="dataTables_paginate paging_bootstrap" id="simpledatatable_paginate">
                                    {$page}
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</block>

<block name="footer">
    <script src="/Public/assets/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>

    <script type="text/javascript">
        function checkCount() {
            return $(".select-item:checked").length;
        }
        $("#sort,#delete,#move a").click(function() {
            var action = $(this).data("action");
            if(!action) return false;
            if (!checkCount()) {
                tips('请选择要操作的数据', 'danger');
                return false;
            }
            var confirmText = $(this).data("confirmtext");
            if(confirmText){
                bootbox.confirm(confirmText,function(flag){
                    if(flag){
                        $("#listForm").attr("action",action).ajaxSubmit(function(result) {
                            result = JSON.parse(result);
                            if (result.status == 'success') {
                                location.reload();
                            } else {
                                tips(result.message, 'danger');
                            }
                        });
                    }
                })
            }else{
                $("#listForm").attr("action",action).ajaxSubmit(function(result) {
                    result = JSON.parse(result);
                    if (result.status == 'success') {
                        location.reload();
                    } else {
                        tips(result.message, 'danger');
                    }
                });
            }

        });
    </script>

</block>